Skip to content

Conversation

@iAmGiG
Copy link
Collaborator

@iAmGiG iAmGiG commented Aug 25, 2025

Minor File reorganization.

nverma42 and others added 30 commits October 12, 2024 15:01
Additional ideas
…ports and fix unused variables

- Refactored the MentalHealthChatbot class:
  - Added absl-py for command-line argument handling.
  - Incorporated Sentence-BERT for query encoding and classification.
  - Added logistic regression for query categorization (informational vs emotional).
  - Implemented KNN for informational responses.
  - Integrated LinearSVC for emotion classification in emotional support queries.

- Improved docstrings across all methods:
  - Clarified method roles, input arguments, return values, and attributes.
  - Added detailed explanations for the purpose and handling of unused variables like 'distances'.
  - Updated LinearSVC-related docstring with classifier usage and purpose.

- Imported missing dependencies:
  - Added 'precision_recall_fscore_support' from sklearn.metrics.
  - Added 'LinearSVC' from sklearn.svm.

- Enhanced modular design:
  - Incorporated best practices by organizing methods into logical segments.
  - Added error handling and console flag management with absl-py.

- Removed or clarified unused variables:
  - Explained 'distances' in get_informational_response if retained or removed when unnecessary.

- Structured code for better maintainability and future enhancements.

- Added instructions in README for setup, including Conda and venv, and running the chatbot.

Each method now has clear docstrings that explain
its purpose, the arguments it takes, and the expected return values.
Additional clarifications and reasoning have been added to provide context for unused variables like distances.
Methods are ordered sequentially, starting from initialization (__init__) to the main execution (run).
Includes cache directories, virtual environments (venv, env), build files, and logs.
VS/VSCode files: Adds .vs/, .vscode/, .idea/, and other Visual Studio-specific files like .suo, .sln.docstates.
Data and Environment files: To prevent sensitive data or local configurations from being committed (like .env files).
MacOS and Jupyter files: Excludes .DS_Store (macOS) and Jupyter checkpoint files.
repository’s history, but they remain on your local machine.
Going forward, these files will be ignored thanks to the .gitignore file, so they won’t be accidentally committed again.
and update chatbot accordingly

- Created 'canned_responses.csv' in the data directory with expanded responses.
- Modified __init__ method to accept canned_responses_path and load responses from CSV.
- Added 'load_canned_responses' method to read canned responses into a dictionary.
- Updated 'get_emotional_response' to use the loaded canned responses.
- Updated main.py and README.md to include the new command-line flag for canned responses path.
- Ensured that the chatbot handles emotions not present in the canned responses gracefully.
Moved the csv file into a data folder
"updated" Project strucutre.graphql - improving accuracy.
updated readme
updated mental_health_chatbot.py
 documentation, and improve runtime logic

- **Refactor MentalHealthChatbot class**:
  - Moved the 'run' method out of the class and into
  'conversation_chatbot_main.py' to follow best practices.
  - Updated imports in the new 'conversation_chatbot_main.py'
  file for better modularity.
  - Updated class method variable names to conform to snake_case
  naming style in 'load_data', 'preprocess_data',
  'train_logistic_classifier', 'build_knn_classifier',
  and 'get_informational_response'.
  - Removed dependency on 'data/canned_responses.csv'
  and incorporated conversation graphs for emotional queries
  based on the mental health counseling conversations dataset.

- **Enhance chatbot interaction**:
  - Expanded termination options in the interactive loop to
  include 'exit', 'quit', 'q', 'x', 'e', and 'Ctrl+C'
  for graceful exits.

- **Update project documentation**:
  - Updated README running instructions to reflect changes in module
  names and data paths.
  - Added project structure section to README with descriptions of
  key files and directories.
  - Provided a module docstring for 'conversation_chatbot_main.py'
  detailing the purpose and usage of the script.
  - Updated the project’s structure in GraphQL format to better
  reflect the file organization.

- **Future-proofing**:
  - Set up a clear separation of concerns between chatbot logic and
  runtime flow to improve maintainability and reusability.
  - Prepared the project for future improvements by updating docstrings,
   adhering to coding best practices, and documenting all key functionality.

This commit includes all updates made during the conversation,
enhancing the overall structure, usability, and clarity of the chatbot project.
removed pycache
removed cannded response .csv
moved test.csv into data - remove later
updated readme.md to have the proper name.
corrected the README.md filename
updated project structure.
Added a new class for emotional response.
Refactor, Documentation Updates, and Runtime Enhancements
organized the imports, and perfromed linting.
Refactor And Integration of Emotional_Response.
- Refactored MentalHealthChatbot class:
  - Removed `train_emotion_classifier` and all `LinearSVC` dependencies, replacing them with the new `EmotionalResponse` class for emotional query handling.
  - Integrated `EmotionalResponse.get_response` method for emotional queries in `respond_to_query`.
  - Simplified data loading to include only FAQ and counseling conversation datasets.
  - depricated get emotional response, train emotional classifier methods.

- Updated conversation_chatbot_main.py runtime:
  - Adjusted `conversations_data_path` to use the Hugging Face dataset URL for real-time access to counseling conversations.
  - Removed unnecessary method calls (e.g., `train_emotion_classifier`) to align with updated class structure.
  - Enhanced exit options and user guidance in the interactive loop for better usability.

- Added detailed docstrings and comments:
  - Documented major methods and clarified logic in both `MentalHealthChatbot` and `conversation_chatbot_main.py`.
  - Provided additional instructions on response handling and runtime behavior.

- Future Enhancements:
  - Outlined the need for integrating summarization in `EmotionalResponse` for a more refined response structure.

This refactor prepares the chatbot for streamlined conversational flow and enables multi-turn interactions based on real counseling data.
    and update classes

- Check for CUDA availability and GPU count in conversation_chatbot_main.py
- Update MentalHealthChatbot and EmotionalResponse classes to accept a device parameter
- Automate device assignment and model loading onto the specified device
- Implement robust error handling and logging
- Ensure compatibility with pre-trained models from HuggingFace
nverma42 and others added 26 commits November 12, 2024 18:24
Merge pull request #8 from nverma42/main
many files where outside of folders including Depricated_Files
Pipeline md isn't using the current updated formate as modified
    previously
fixed snake case of Model_Comparison filename
moved Visuals into respective folder
metrics moved into Metrics folder
removed protject structure graphql - depricated
moved MentalHealthChatbotCodeDocument into Depricated_Files but might
    revive
that implements the MMR-based.
Here are the key improvements and features:

Sentence Transformer Integration:
Uses the sentence-transformers library for high-quality sentence embeddings
Configurable model selection (defaults to 'paraphrase-MiniLM-L6-v2')
GPU support through device parameter

MMR Algorithm Implementation:
Implements Maximal Marginal Relevance as specified
Configurable λ parameter (default 0.7)
Balances relevance to query with diversity in selected sentences

Enhanced Sentence Processing:
Improved sentence splitting with abbreviation handling
Maintains sentence ordering as specified
Returns original indices for traceability

Rich Output:
Returns detailed metadata about the summarization process
Includes similarity scores and selected indices
Error handling with informative messages
summarization_engine_V2 was appart of a cherry-pick from another
branch, fishing the merge with a removal.
…ng process for both single and multi-GPU setups

Updated all methods that use encoding to use the new wrapper method
Maintained the original SentenceTransformer instance as base_encoder
…proper device management

Added batch processing for large datasets to prevent memory issues
Added proper error handling for out-of-memory scenarios
Improved device handling with proper type checking
Added memory cleanup when needed
Improved initialization with proper placeholder setup
Added proper device handling and conversion
Created a new encode_text method with:

Batch processing support
Better error handling
Memory management
Proper device fallback

Improved error handling in get_response
Added more empathetic default responses
Better handling of edge cases

The file also needs a few imports at the top
removed duplicate lines.
update doc strings for methods.
Major restructuring of the codebase for better maintainability and professional presentation:

**Repository Structure:**
- Move core modules to src/ directory with proper package structure
- Organize tests in tests/ directory with comprehensive test coverage
- Create scripts/ directory for utility and analysis tools
- Establish docs/ directory for documentation
- Add setup.py for pip-installable package

**Documentation Improvements:**
- Comprehensive rewrite of Pipeline.md with detailed technical specifications
- Enhanced README.md with feature highlights and improved setup instructions
- Added technical details for MMR summarization algorithm
- Documented conversation graph architecture and LDA topic modeling

**Code Organization:**
- Remove deprecated files and consolidate functionality
- Update .gitignore with comprehensive coverage for Python projects
- Clean up legacy visualization files and unused test modules
- Maintain backward compatibility while improving structure

This reorganization establishes a professional foundation for future development and makes the project more accessible to contributors.
@iAmGiG iAmGiG requested a review from nverma42 August 25, 2025 18:29
@iAmGiG iAmGiG added the Refactoring Project For when the repo needs refactoring to be usable. label Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactoring Project For when the repo needs refactoring to be usable.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants